<template>
  <div id="app">
    <ErrorBoundary>
      <router-view />
    </ErrorBoundary>
  </div>
</template>

<script setup>
import { onErrorCaptured } from 'vue'
import ErrorBoundary from '@/components/ErrorBoundary.vue'

// 全局错误处理
onErrorCaptured((err, _vm, info) => {
  console.error('Global error captured:', err, info)
  return false
})

// 全局未捕获错误处理
window.addEventListener('error', (event) => {
  console.error('Global uncaught error:', event.error)
})

// 全局未捕获Promise错误处理
window.addEventListener('unhandledrejection', (event) => {
  console.error('Global unhandled promise rejection:', event.reason)
  event.preventDefault()
})
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  height: 100vh;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}
</style>
